package de.clapp.backend;

import java.awt.Color;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;

import javax.swing.JScrollPane;
import javax.swing.ListSelectionModel;
import javax.swing.table.JTableHeader;

import org.jdesktop.swingx.JXTable;
import org.jdesktop.swingx.decorator.HighlighterFactory;

import de.clapp.backend.clublist.ClublistModel;
import de.clapp.backend.clublist.ClublistTableModel;
import de.clapp.panels.MyTabbedPanel;

@SuppressWarnings("serial")
public class ClublistPanel extends MyTabbedPanel
{
    private final JXTable table;

    public ClublistPanel()
    {
        this.setLayout(new GridBagLayout());
        
        final ClublistTableModel tableModel = new ClublistTableModel();
        this.table = new JXTable(tableModel);
        this.table.setOpaque(false);
        table.setHighlighters(HighlighterFactory.createAlternateStriping());
        table.setFont(new Font("Arial", Font.PLAIN, 14));
        table.setRowHeight(20);
        table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);

        JTableHeader header = table.getTableHeader();
        header.setBackground(new Color(240, 245, 250));
        header.setFont(new Font("Arial", Font.BOLD, 12));

        ClublistModel.getI().refresh();
        
        /**
         * Tabelle
         */
        GridBagConstraints c = new GridBagConstraints();
        c.weightx = 1;
        c.weighty = 1;
        c.fill = GridBagConstraints.BOTH;
        c.gridx = 0;
        c.gridy = 0;
        c.gridheight = 1;
        c.gridwidth = 1;
        c.insets = new Insets(0, 5, 5, 0);
        
        JScrollPane scrollPane = new JScrollPane(table);
        scrollPane.getViewport().setOpaque(false);
        scrollPane.setOpaque(false);
        this.add(scrollPane, c);
        
        this.setVisible(true);
    }
}
